package com.net.library.nettoken;


import com.net.library.constant.SharePreKey;
import com.net.library.util.SharedPreferencesUntil;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

/**
 * author 吴昶
 * date 2019/6/3
 * 标注
 */
public class MyHttpLoggingInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        String value= SharedPreferencesUntil.getValue(SharePreKey.ACCESS_TOKEN,"").toString();
        String sid=SharedPreferencesUntil.getValue(SharePreKey.SID,"").toString();
        Request original = chain.request();
        Request.Builder requestBuilder = original.newBuilder()
                .header("Authorization", "Bearer $value")
                .header("sid",sid);
        Request request = requestBuilder.build();
        return chain.proceed(request);
    }
}
